package cn.bone.springcloud.base.conf;

import org.springframework.cloud.gateway.route.Route;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class GatewayConfig {

    @Bean
    public RouteLocator constomRoutes(RouteLocatorBuilder builder){
        RouteLocatorBuilder.Builder routes = builder.routes();
        routes.route("path_route_baidu", r -> {
            Route.AsyncBuilder asyncBuilder = r.path("/guonei")
                    .uri("https://news.baidu.com/guonei");
            return asyncBuilder;
        })
        .route("path_route_baidu2", r->{
            Route.AsyncBuilder asyncBuilder = r.path("/guoji")
                    .uri("https://news.baidu.com/guoji");
            return asyncBuilder;
        });

        return routes.build();
    }
}
